<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!--********************************************************************
* 该示例需要引入
* iclient-plot-leaflet (https://iclient.supermap.io/web/libs/plotting/leaflet/12.0.0.0/iclient-plot-leaflet.min.js)
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title data-i18n="resources.title_editPlottingLayer"></title>
</head>
<body  style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="toolbar" class="panel panel-primary" style=" position: absolute;top: 10px;right: 10px;text-align: center;z-index: 9999;border-radius: 4px;">
    <div class='panel-heading' id="panelheading">
        <h5 class='panel-title text-center' data-i18n="resources.title_editPlottingLayer"></h5></div>
    <div class='panel-body content' id="panelbodycontent">
        <div class='panel'>
            <div class='input-group' style=" margin-bottom: 12px;width: 240px;">
                <span class='input-group-addon' data-i18n="resources.text_editLayer"></span>
                <select class='form-control' id='editable' onchange="editableChanges()">
                    <option value='0'>false</option>
                    <option value='1' selected>true</option>
                </select>
            </div>
            <div class='input-group' style=" margin-bottom: 12px;width: 240px;">
                <span class='input-group-addon' data-i18n="resources.text_lockLayer"></span>
                <select class='form-control' id='locked' onchange="lockedChanges()">
                    <option value='0' selected>false</option>
                    <option value='1'>true</option>
                </select>
            </div>
            <div class='input-group' style=" margin-bottom: 12px;width: 240px;">
                <span class='input-group-addon' data-i18n="resources.text_selectLayer"></span>
                <select class='form-control' id='selected' onchange="selectedChanges()">
                    <option value='0'>false</option>
                    <option value='1' selected>true</option>
                </select>
            </div>
        </div>
        <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_drawMarker" style="margin-bottom: 10px" onclick="plotSymbol()"/>
        <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_cancelMarker" style="margin-bottom: 10px" onclick="plottingDrawCancel()"/>
    </div>
</div>
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" include="bootstrap-css" src="../js/include-web.js"></script>
<script type="text/javascript" include="iclient-plot-leaflet" src="../../dist/leaflet/include-leaflet.js"></script>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var url = host + "/iserver/services/map-china/rest/maps/China_4326";
    var serverUrl = host + "/iserver/services/plot-jingyong/rest/plot/";
    var map,drawControl,editFlag,lockedFlag,selectedFlag;
    map = L.map('map', {
        preferCanvas: true,
        crs: L.CRS.EPSG4326,
        center: [35,104],
        maxZoom: 18,
        zoom: 3
    });
    new L.supermap.TiledMapLayer(url).addTo(map);
    var plottingLayer = L.supermap.plotting.plottingLayer("plot", serverUrl);
    plottingLayer.addTo(map);
    var drawControl = L.supermap.plotting.drawControl(plottingLayer);
    drawControl.addTo(map);
    var editControl = L.supermap.plotting.editControl();
    editControl.addTo(map);
    function editableChanges(){
        if(document.getElementById("editable").selectedIndex === 0){
            editFlag = false;
        }else{
            editFlag = true;
        }
        plottingLayer.setEditable(editFlag);
    }

    function lockedChanges(){
       if(document.getElementById("locked").selectedIndex === 0){
           lockedFlag = false;
       }else{
           lockedFlag = true;
       }
        plottingLayer.setLocked(lockedFlag);
    }
    function selectedChanges(){
        if(document.getElementById("selected").selectedIndex === 0){
            selectedFlag = false;
        }else{
            selectedFlag = true;
        }
        plottingLayer.setSelected(selectedFlag);
    }
    function plotSymbol(){
            drawControl.handler.libID = 0;
            drawControl.handler.code = 32;
            drawControl.handler.serverUrl = serverUrl;
            drawControl.handler.enable();

    }
    function plottingDrawCancel(){
        drawControl.handler.disable();
    }
    $(document).ready(function(){
        $('#panelheading').click(function(){
            $('#panelbodycontent').toggle();
        });
    });
</script>
</body>
</html>